import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: ()=> import('../views/login'),
    meta:{
      name:"登录",
    },
  },
  {
    path: '/register',
    name: 'register',
    component: ()=> import('../views/register'),
    meta:{
      name:"注册",
    },
  },
  {
    path: '/blankPage',
    name: 'blankPage',
    component: ()=> import('../views/blankPage'),
    meta:{
      name:"空白页",
    },
  },
  {
    path: '/admin/page/:uid',
    name: 'page',
    component: ()=> import('../views/admin/userPage'),
    meta:{
      name:"管理员主页",
      requireAuth: true
    },
    children:[
      {
        path: '/admin/page/member',
        name: 'member',
        component: ()=> import('../views/admin/item/memberHome'),
        meta:{
          name:"成员信息概述",
          requireAuth: true
        },
      },
      {
        path: '/admin/page/memberinfo/:index',
        name: 'memberinfo',
        component: ()=> import('../views/admin/item/memberInfo'),
        meta:{
          name:"成员介绍",
        },
      },
      {
        path: '/admin/page/membermyself',
        name: 'membermyself',
        component: ()=> import('../views/admin/item/memberMyself'),
        meta:{
          name:"账号设置",
        },
      },
      {
        path: '/admin/page/memberpro',
        name: 'memberpro',
        component: ()=> import('../views/admin/item/memberPro'),
        meta:{
          name:"项目信息",
        },
      },
      {
        path: '/admin/page/bookmanage',
        name: 'bookmanage',
        component: ()=> import('../views/admin/item/bookmanage/bookManage'),
        meta:{
          name:"图书管理",
        },
      },
      {
        path: '/admin/page/usermanage',
        name: 'usermanage',
        component: ()=> import('../views/admin/item/usermanage/userManage'),
        meta:{
          name:"用户管理",
        },
      },
      {
        path: '/admin/page/lunbomanage',
        name: 'LunBoManage',
        component: ()=> import('../views/admin/item/lunbomanage/LunBoManage'),
        meta:{
          name:"轮播图管理",
        },
      },
    ]
  },
  //  404页面，
  {
    path: '/404',
    name: 'Error',
    component: ()=> import('../views/Error'),
    meta:{
      name:"页面出错啦!",
    },
  },
    // 所有未定义路由，全部重定向到404页面
  {
   path:"*",//匹配所有路由
   redirect:"/404",//重定向
  }



]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach(function (to,form,next) {
  // console.log(to);
  // console.log(form);

  document.title=to.meta.name;
  next();
});
export default router
